<template>
  <div>
    <ul>
      <li v-for="(item,index) in arr" :key="index">{{item}}
      <button @click="del(index)">删除</button>
      </li>
    </ul>
    <button @click="add">生成</button>
  </div>
</template>

<script>
export default {
data(){
  return {
    arr:[1,3,5]
  }
},
methods:{
  add(){
    let num=Math.floor(Math.random()*20)
    this.arr.push(num)
  },
  del(n){
    this.arr.splice(n,1)
  }
}
}
</script>

<style>

</style>